package com.aide.simplification.popedom.popedom.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.directwebremoting.annotations.RemoteMethod;

import com.aide.simplification.global.Utils;
import com.aide.simplification.global.db.DatabaseOP;
import com.aide.simplification.popedom.Publiclass;
import com.aide.simplification.popedom.login.LoginUser;
import com.aide.simplification.popedom.login.PopSSO;

public class BasePop {
	protected DatabaseOP dbop;
	protected Publiclass pc;

	public BasePop() {
		dbop = new DatabaseOP("pop");
		pc = new Publiclass();
	}

	@RemoteMethod
	public boolean isAdmin(HttpServletRequest request,
			HttpServletResponse response) {
		PopSSO sso = new PopSSO(request, response);
		LoginUser lu = sso.ssoSync();
		if (lu != null) {
			return lu.getUseruuid().equals(Utils.getConfig("pop.admin"));
		}
		return false;
	}


	@RemoteMethod
	public boolean checkPopAnd(String pagepop, HttpServletRequest request,
			HttpServletResponse response) {
		PopedomOP pop = new PopedomOP();
		return pop.checkPopAndByUser(pagepop, request, response);
	}

	@RemoteMethod
	public boolean checkPopOr(String pagepop, HttpServletRequest request,
			HttpServletResponse response) {

		PopedomOP pop = new PopedomOP();
		return pop.checkPopOrByUser(pagepop, request, response);
	}
}
